var Take6Model = require("Take6Model");

var EventModel = cc.Class({
    extends: cc.Component,

    properties: {
        nPlayersNotSendCard : []
    },

    onLoad: function () 
    {
        for (var i = 0; i < 4; i++)
        {
            this.nPlayersNotSendCard.push(i);
        }
    },

    postEvent: function ()
    {
        var nNotSendCardCount = this.nPlayersNotSendCard.length;
        cc.log("nNotSendCardCount :", nNotSendCardCount);
        var nIndex = parseInt(Math.random() * (nNotSendCardCount));
        cc.log("nIndex :", nIndex);
        var nPlayerIndex = this.nPlayersNotSendCard.splice(nIndex, 1);
        cc.log("nPlayerIndex :", nPlayerIndex);

        Take6Model.getAServerCard(parseInt(nPlayerIndex), Take6Model.getACard());

        if (nNotSendCardCount == 1)
        {
            for (var i = 0; i < 4; i++)
            {
                this.nPlayersNotSendCard.push(i);
            }
        }
    },

    start () {

    },

    // update (dt) {},
});

module.exports = EventModel;